<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="apple-mobile-web-app-capable" content="yes" />
        <meta name="apple-mobile-web-app-status-bar-style" content="black" />
        <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0, maximum-scale=1.0, minimal-ui" />
        
        <title>Insert Element After Documentation</title>
        
        <script src="/js/greyspots.js" type="text/javascript"></script>
        <link href="/css/greyspots.css" type="text/css" rel="stylesheet" />
        
        <script src="/js/ace/ace.js" data-ace-base="/js/ace/" type="text/javascript" charset="utf-8"></script>
        <script src="/js/ace/ext-language_tools.js" type="text/javascript"></script>
        <script src="/js/ace/ext-searchbox.js" type="text/javascript"></script>
        
        <script src="doc-library/doc.js" type="text/javascript"></script>
        <link href="doc-library/doc.css" type="text/css" rel="stylesheet" />
    </head>
    <body>
        <gs-jumbo>
            <h1 class="text-center">Insert Element After</h1>
        </gs-jumbo>
            
        <gs-container min-width="sml;med;lrg">
            <h3>Function:</h3>
            <pre><code>GS.insertElementAfter(&lt;ELEMENT-TO-INSERT&gt;, &lt;TARGET&gt;)</code></pre>
            
            <h3>Description:</h3>
            <p>This function fills in a missing Javascript DOM manipulation function: inserting an element after another element. Currently Javascript can append an element into another and insert an element before another, but not insert after.</p>
            
            <h1>Examples:</h1>
            <div class="doc-example-description">
                <span class="h3">GS.insertElementAfter Example:</span><br />
                <p>When you click the "Insert Element" button a div element with some text inside will be inserted right after the button.</p>
            </div>
            <gs-doc-example>
                <template for="html" height="5">
                    <gs-button id="target" onclick="testInsert()">
                        Insert Element
                    </gs-button>
                </template>
                <template for="js" height="19">
                    var i = 0;
                    
                    function testInsert() {
                        var element = document.createElement('div');
                        
                        i += 1;
                        element.textContent = 'This is: test div ' + i;
                        
                        GS.insertElementAfter(
                            element,
                            document.getElementById('target')
                        );
                    }
                </template>
            </gs-doc-example>
        </gs-container>
    </body>
</html>